const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    videoUrl: '',
    videoData:null,
    is_cover:true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this
    var video = wx.createVideoContext('video', that);
    // console.log(options);
    if (options.type == "shareArticle") {
      var id = options.id
      wx.setStorageSync('artId', id)
      wx.switchTab({
        url: '/pages/index/index',
        success: (res) => {}
      });
    } else if (options.type == "shareVideo") {
      that.setData({
        videoId:options.id
      })
      wx.request({
        url: app.globalData.url + 'medias/query_video?id=' + options.id,
        success: (res) => {
          
          that.setData({
            videoData: res.data.data,
            videoUrl: res.data.data.play_url
          })
          // video.play()
          // video.requestFullScreen({
          //   fail: function(e) {
          //     console.log(e);
          //   }
          // })
        }
      });
    }
  },

  // 回到首页
  back: function() {
    wx.switchTab({
      url: '/pages/index/index',
      success: (res) => {}
    });
  },

  play:function(){
    var that = this
    var video = wx.createVideoContext('video', that);
    video.play()
    that.setData({
      is_cover:false
    })
  },
})